package com.kmmlearn.findtime.android.ui.components

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun StickyHeaderList() {
    val items = (1..60).map { "Item $it" }
    val groups = listOf("Group A", "Group B", "Group C")

    LazyColumn {
        groups.forEachIndexed { index, group ->
            stickyHeader {
                Surface(
                    modifier = Modifier.fillMaxWidth(),
                    color = MaterialTheme.colorScheme.primary
                ) {
                    Text(
                        text = group,
                        modifier = Modifier.padding(18.dp),
                        color = MaterialTheme.colorScheme.onPrimary
                    )
                }
            }
            items(items.drop(index * 20).take(20)) { item ->
                Text(
                    text = item,
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(18.dp)
                )
            }
        }
    }
}
